package com.example.demoweb.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author 赵恒
 * @date 2023/5/12
 * Swagger 配置页面
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docketYichang() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .groupName("默认")
                .select().apis(RequestHandlerSelectors.basePackage("com.example.demoweb.controller"))
                .build();
    }

    // String title, String description, String version, String termsOfServiceUrl, Contact contact, String license, String licenseUrl, Collection<VendorExtension>
    @Bean
    public ApiInfo getApiInfo() {
        // Contact(String name, String url, String email)
        Contact contact = new Contact("hxlc", "https://www.baotao.com", "898773575@qq.com");
        return new ApiInfo("web接口测试", "测试SpringMVC中各种参数的输入与解析", "1.0", "url", contact, "Apache Foundation", "http://www.baidu.com", new ArrayList<>());
    }
}
